import {createApp, onMounted} from 'vue'
import './style.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import pinia from './store'
import router from './router'
import "@/mock" // mock数据
import HeaderWrapper from "./components/headerWrapper";
import Footer from "./components/footer";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import "./permissionRoute.js"
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(pinia);
app.use(router)
app.use(ElementPlus)
app.component("HeaderWrapper",HeaderWrapper);
app.component("Footer",Footer);
app.mount('#app')

//自定义指令  滚动最底部自动刷新
app.directive('load',{
    mounted(el, binding) {
        const SELECTWRAP_DOM = el;
        SELECTWRAP_DOM.addEventListener('scroll', function() {
            const condition =
                SELECTWRAP_DOM.scrollHeight - SELECTWRAP_DOM.scrollTop <= SELECTWRAP_DOM.clientHeight;
            if (condition) {
                binding.value();
            }
        });
    }
});
//全局注册中文分页器
import locale from 'element-plus/lib/locale/lang/zh-cn'
// 注意!!!这句必须跟在const app= xxxx  之后
app.use(ElementPlus, { locale });


